package com.ai_daily.aitiantian.api

import com.ai_daily.aitiantian.BuildConfig
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import java.util.concurrent.TimeUnit

object SeeOkHttpClientManager {
    private val okHttpClient = OkHttpClient.Builder()
        .addInterceptor(provideLoggingInterceptor())
        .callTimeout(600, TimeUnit.SECONDS)
        .build();

    /**
     * OkHttp 日志拦截器
     */
    private fun provideLoggingInterceptor(): HttpLoggingInterceptor {
        return HttpLoggingInterceptor().apply {
            level = if (BuildConfig.DEBUG) {
                // debug 模式打印全部信息
                HttpLoggingInterceptor.Level.BODY
            } else {
                HttpLoggingInterceptor.Level.NONE // no logs
            }
        }
    }

    fun getOkHttpClient(): OkHttpClient {
        return okHttpClient
    }

}